package alipay.openplatform.edu.campus.jiuye.common.utils;

import org.apache.commons.beanutils.BeanUtilsBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zong on 16/9/16.
 */
public class CopyVoPo {

    public static  final BeanUtilsBean beanUtilsBean = new BeanUtilsBean();

    /**
     * 进行LIST<PO>,LIST<VO>的数据拷贝
     *
     * @param poList   po对象的列表
     * @param voClass  vo对象类
     * @return List    返回转化后的VO列表对象
     */
    public static List copyList (List<? extends Object> poList , Class voClass){

        List voList=new ArrayList();

        Object voObj = null;
        for(Object poObj:poList){
            try {
                voObj = voClass.newInstance();
            } catch (InstantiationException | IllegalAccessException e) {
                e.printStackTrace();

            }
            try {
                beanUtilsBean.copyProperties(voObj, poObj);
                voList.add(voObj);
            }
            catch (Exception e)
            {

            }
        }


        return voList;

    }
}
